Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Using program variables and data types
Like most programming languages, the Progress 4GL lets you define program variables for use within a procedure. Here is the basic syntax:
In this syntax,
varnameis the name of the variable, which must conform to the same rules as other names in the 4GL. (See the "Variable naming conventions" section for details.)Progress supports a range of data types. Table 2–2 lists the basic ones. There are some other special data types available for more advanced programming, but these are enough to get you started.
Here are a few notes on Progress data types:
- All
CHARACTERdata in Progress variables, and in database fields in an OpenEdge database, is stored as variable length strings. You do not need to define the length of a variable, only its display format, which indicates how many characters (at most) are displayed to the user. The default display length forCHARACTERfields is 8 characters. The X symbol represents any printable character, and the 8 in parentheses effectively repeats that character, so that X(8) is the same as XXXXXXXX. The default value for aCHARACTERvariable is the empty string.- You can display dates in a variety of ways, including two- or four-digit years. To get a four-digit year, specify 99/99/9999 as your format. Note that changing the display format for a date does not change how it is stored in the database. Dates are stored in an internal format that can be converted to any of the display formats available to you.
- The
DECIMALdata type supports a total of 50 digits of which up to 10 can be to the right of the decimal point. When you define aDECIMALvariable you can specify the number of positions to the right of the decimal point by adding the qualifierDECIMALS <n>to theDEFINE VARIABLEstatement.- Progress supports the automatic conversion of both
DATEs andDECIMALs to the formats generally used in Europe and other parts of the world outside the US. If you use the European (–E) startup option, then all period or decimal characters inDECIMALformats are converted to commas, and commas are converted to periods. In addition, the defaultDATEdisplay becomes DD/MM/YY or DD/MM/YYYY instead of MM/DD/YY or MM/DD/YYYY.- The
HANDLEdata type is used to store a pointer to a structure that represents a running Progress procedure or an object in a procedure such as a field or button. Chapter 18, "Using Dynamic Graphical Objects," and Chapter 19, "Using Dynamic Queries and Buffers," provide more information about how to useHANDLEvariables.- The maximum size of an
INTEGERvariable is 2G (slightly over a billion digits).- A
LOGICALvariable represents a yes/no or true/false value. You can specify any pair of literals you wish for the TRUE and FALSE values that are displayed to the user for aLOGICALvariable, with the TRUE or YES value first. However, it is not advisable to useLOGICALs to represent data values that aren’t really logical by nature, but which simply happen to have two valid values, such as Male/Female, because it might be unclear which of those the TRUE value represents.- You will learn about the Progress Unknown value (
?) in the "Using the Progress Unknown value" section. The default display format forDATEthat has the Unknown value (?) is blank; for other data types it is a question mark.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |